package com.only4play.portal.common.bean;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;

/**
 * @author liyuncong
 * @version 1.0
 * @file PortalAccessToken
 * @brief PortalAccessToken
 * @details PortalAccessToken
 * @date 2024-06-07
 *
 * Edit History
 * ----------------------------------------------------------------------------
 * DATE                     NAME               DESCRIPTION
 * 2024-06-07               liyuncong          Created
 */

@Getter
@Setter
public class AccessToken implements Serializable {

    private String accessToken;

    private int expiresIn = -1;

    public static AccessToken fromJson(String json) {
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            return objectMapper.readValue(json, AccessToken.class);
        } catch (JsonProcessingException exception) {
            return null;
        }
    }
}
